﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_ControlGetDuplicatedCust : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            LoadMonthLy();
            LoadGrid();
        }

    }

    protected void BtnSave_Click(object sender, EventArgs e)
    {
        LoadGrid();
    }
  
    void LoadGrid()
    {

        dt = new ClassExecute.ClassExecute();
        try
        {
           
              DataTable db = dt.Get_Data_DataTable(str, ref error, "[k_checkDuplicatedCust]", CommandType.StoredProcedure,
                     new SqlParameter("@Sitecode", drlDistributor.SelectedValue.ToString()),
                     new SqlParameter("@YyyyMm",DropMonthy.SelectedValue.ToString()));

            if (db.Rows.Count > 0)
            {
                grvIntxd.DataSource = db;

            }
            else
            {
                grvIntxd.DataSource = null;
                ShowMessageBox("Không có dữ liệu");
            }
            grvIntxd.DataBind();
        }
        catch (Exception ex)
        {

            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);
        }
    }
    void ShowMessageBox(string text)
    {
        MessageBox.Text = text;
        MessageBox.ShowOnPageLoad = true;
    }
    void LoadMonthLy()
    {
        dt = new ClassExecute.ClassExecute();
        try
        {

            DataTable db = dt.Get_Data_DataTable(str, ref error, "k_getMonthly", CommandType.StoredProcedure);
            dt.BindDropDownList(db, DropMonthy, "ID", "Des");
        }
        catch (Exception ex)
        {

            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            dt.WriteErrorLog(Server.MapPath(webapp4U.Globals.LogUrl()), ex.Message, method);
        }
    }
}